Thumb2 ASM, Curve25519#6607
Conversation
|
Note @JacobBarthelmeh or @lealem47 : We'll need to make sure the two new port/arm thumb2 files get added to the CMSIS packs here: https://github.com/wolfSSL/scripts/blob/master/CMSIS/CubePack/wolfSSL/Files/wolfSSL.I-CUBE-wolfSSL.pdsc#L207C24-L207C24 |
dgarske
left a comment
There was a problem hiding this comment.
Should I only expect CURVE25519 to work / be accelerated?
CURVE25519 test passed!
ED25519 test failed!
error L=31069 i=0
[fiducial line numbers: 7803 23957 34911 47088]
Note: I am using these build options:
#define WOLFSSL_ARM_ARCH 7
#define WOLFSSL_ARMASM_NO_HW_CRYPTO
#define WOLFSSL_ARMASM_NO_NEON
#define WOLFSSL_ARMASM
There was a problem hiding this comment.
With CURVED25519_SMALL fe does not exist:
make: *** Waiting for unfinished jobs....
../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/port/arm/thumb2-curve25519_c.c:52:19: error: unknown type name 'fe'
52 | void fe_frombytes(fe out, const unsigned char* in)
| ^~
Seems the new thumb2 code only supports the large build option?
There was a problem hiding this comment.
Yes. Made it so that building small will not compile this file
There was a problem hiding this comment.
When building from sources where armv8-32-curve25519_c.c gets included it produces build errors. Example:
../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c:56:34: error: invalid initializer
56 | register fe out asm ("r0") = out_p;
| ^~~~~
../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c: In function 'fe_tobytes':
../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c:102:38: error: invalid initializer
102 | register const fe n asm ("r1") = n_p;
| ^~~
There was a problem hiding this comment.
Also issues with armv8-*.c being included for people not using configure. Those will likely need some macro protections. Also between the inline .S and .C version of the thumb2. No build option to gate the inline, so manually excluded .S.
There was a problem hiding this comment.
Changed it so that WOLFSSL_ARMASM_INLINE is required for the C file to be built. If not defined the assembly file will build.
There was a problem hiding this comment.
I've put protection around each arm32 and thumb2 asm file to check whether or not thumb is defined.
|
Note: The wolfCrypt test past in release mode for ED25519. Benchmark results on STM32H723 (Cortex M7) at 550MHz (-Os): Using Using the normal software "large" implementation in Using the small implementation in |
ca43133 to
cc21a8b
Compare
|
Updated benchmarks: Benchmark results on STM32H723 (Cortex M7) at 550MHz (-Os): Using Using the normal software "large" implementation in Using the small implementation in |
7da98ca to
263d5bf
Compare
|
Updated benchmarks: Benchmark results on STM32H723 (Cortex M7) at 550MHz (-Os): Build options: |
263d5bf to
5189f70
Compare
dgarske
left a comment
There was a problem hiding this comment.
Amazing work!
STM32H723 (Cortex M7) at 550MHz (-Os):
SHA-256 4 MiB took 1.000 seconds, 3.882 MiB/s
SHA-512 3 MiB took 1.000 seconds, 2.686 MiB/s
CURVE 25519 key gen 398 ops took 1.000 sec, avg 2.513 ms, 398.000 ops/sec
CURVE 25519 agree 412 ops took 1.004 sec, avg 2.437 ms, 410.359 ops/sec
ED 25519 key gen 1261 ops took 1.000 sec, avg 0.793 ms, 1261.000 ops/sec
ED 25519 sign 818 ops took 1.000 sec, avg 1.222 ms, 818.000 ops/sec
ED 25519 verify 346 ops took 1.003 sec, avg 2.899 ms, 344.965 ops/sec
#define WOLFSSL_ARM_ARCH 7
#define WOLFSSL_ARMASM_NO_HW_CRYPTO
#define WOLFSSL_ARMASM_NO_NEON
#define WOLFSSL_ARMASM
#define WC_NO_CACHE_RESISTANT
1437040 to
1e467e2
Compare
1e467e2 to
574261c
Compare
|
Retest this please |
|
@SparkiDev : If enabling just ED25519 with the new Thumb feature I get errors. Does the ASM require both Curve25519 and Ed25519 be enabled? If I enable only ED25519 verify there is only one error: |
|
Retest this please |
2 similar comments
|
Retest this please |
|
Retest this please |
Add support for compiling ASM for Thumb2 Add Curve25519 ASM for Thumb2 Limit assembly code compiled when Ed25519 not required. Rework all assembly implementations to replace ge_*() functions instead of having fe_ge_*() versions that take many parameters. Get ARM32 inline asm working.
574261c to
36b92a4
Compare
|
I believe I've fixed the issue with building only ED25519. |
dgarske
left a comment
There was a problem hiding this comment.
Fully tested and meets customers expectations. Thanks Sean!
Description
Add support for compiling ASM for Thumb2
Add Curve25519 ASM for Thumb2
Limit assembly code compiled when Ed25519 not required.
If ED25519 verify only is needed the sign/keygen can be disabled to reduce code size. The base point is only needed for public key generation (signing/keygen). Use these build options:
#define NO_ED25519_MAKE_KEYand#define NO_ED25519_SIGNTesting
./configure '--disable-shared' 'LDFLAGS=--static' '--host=armv7m' 'CC=arm-linux-gnueabi-gcc' '--enable-curve25519' '--enable-ed25519' '--enable-cryptonly' '--enable-armasm'
Checklist